package com.ddpyjqtd.singleton;

import java.io.Serializable;

/**
 * @Description: 静态内部类
 * 
 * @author: ddpyjqtd
 * @Date: 2019年3月9日
 *
 */
public class StaticInnerClass implements Serializable {

	private static final long serialVersionUID = 8603106601990750963L;
	private static boolean HAS_CREATER = false;

	private StaticInnerClass() {
		if (!HAS_CREATER) {// 防止反射获取多个不同对象的漏洞
			HAS_CREATER = true;
		}
		if (HAS_CREATER) {
			throw new RuntimeException("单例已被破坏");
		}

	}

	public static StaticInnerClass getInstance() {
		return InnerClass.innerClass;
	}

	private static class InnerClass {
		public static final StaticInnerClass innerClass = new StaticInnerClass();
	}
}
